
package bean;

import model.info.Level;

public class CharacterBEAN {
	private int		characterID;
	private int		health;
	private String	charName;
	private int		experience;
	private int		level;
	private int		moneyCash, moneyBank;
	private int		equipment;
	private int		shootExperience;
	private int		respect;
	private int		networkID;
	private int		land;
	private int		object;
	private boolean	vip;
	private boolean	administrator;
	private int		home;
	private int		mailID;
	private int		backfire;

	/**
	 * @param characterID
	 * @param health
	 * @param charName
	 * @param experience
	 * @param level
	 * @param moneyCash
	 * @param moneyBank
	 * @param equipment
	 * @param shootExperience
	 * @param respect
	 * @param networkID
	 * @param land
	 * @param object
	 * @param vip
	 * @param administrator
	 * @param home
	 * @param arrayList
	 */
	public CharacterBEAN( int characterID, int health, String charName,
			int experience, int level, int moneyCash, int moneyBank,
			int equipment, int shootExperience, int respect, int networkID,
			int land, int object, boolean vip, boolean administrator, int home,
			int mailID, int backfire ) {
		super();
		this.characterID = characterID;
		this.health = health;
		this.charName = charName;
		this.experience = experience;
		this.level = level;
		this.moneyCash = moneyCash;
		this.moneyBank = moneyBank;
		this.equipment = equipment;
		this.shootExperience = shootExperience;
		this.respect = respect;
		this.networkID = networkID;
		this.land = land;
		this.object = object;
		this.vip = vip;
		this.administrator = administrator;
		this.home = home;
		this.mailID = mailID;
		this.setBackfire( backfire );
	}

	public int getCharacterID() {
		return characterID;
	}

	public void setCharacterID( int characterID ) {
		this.characterID = characterID;
	}

	public int getHealth() {
		return health;
	}

	public void setHealth( int health ) {
		this.health = health;
	}

	public String getCharName() {
		return charName;
	}

	public void setCharName( String charName ) {
		this.charName = charName;
	}

	public int getExperience() {
		return experience;
	}

	public void setExperience( int experience ) {
		this.experience = experience;
	}

	public int getLevel() {
		return level;
	}

	public void setLevel( int level ) {
		this.level = level;
	}

	public int getMoneyCash() {
		return moneyCash;
	}

	public void setMoneyCash( int moneyCash ) {
		this.moneyCash = moneyCash;
	}

	public int getMoneyBank() {
		return moneyBank;
	}

	public void setMoneyBank( int moneyBank ) {
		this.moneyBank = moneyBank;
	}

	public int getEquipment() {
		return equipment;
	}

	public void setEquipment( int equipment ) {
		this.equipment = equipment;
	}

	public int getShootExperience() {
		return shootExperience;
	}

	public void setShootExperience( int shootExperience ) {
		this.shootExperience = shootExperience;
	}

	public int getRespect() {
		return respect;
	}

	public void setRespect( int respect ) {
		this.respect = respect;
	}

	public int getNetworkID() {
		return networkID;
	}

	public void setNetworkID( int networkID ) {
		this.networkID = networkID;
	}

	public int getLand() {
		return land;
	}

	public void setLand( int land ) {
		this.land = land;
	}

	public int getObject() {
		return object;
	}

	public void setObject( int object ) {
		this.object = object;
	}

	public boolean isVip() {
		return vip;
	}

	public void setVip( boolean vip ) {
		this.vip = vip;
	}

	public boolean isAdministrator() {
		return administrator;
	}

	public void setAdministrator( boolean administrator ) {
		this.administrator = administrator;
	}

	public int getHome() {
		return home;
	}

	public void setHome( int home ) {
		this.home = home;
	}

	public int getMailID() {
		return mailID;
	}

	public void setMailID( int mailID ) {
		this.mailID = mailID;
	}

	@Override
	public String toString() {
		return "CharacterBEAN [characterID=" + characterID + ", health="
				+ health + ", charName=" + charName + ", experience="
				+ experience + ", level=" + level + ", moneyCash=" + moneyCash
				+ ", moneyBank=" + moneyBank + ", equipment=" + equipment
				+ ", shootExperience=" + shootExperience + ", respect="
				+ respect + ", networkID=" + networkID + ", land=" + land
				+ ", object=" + object + ", vip=" + vip + ", administrator="
				+ administrator + ", home=" + home + "]";
	}

	public String getMenuString( CharacterBEAN c ) {
		return "Health: "
				+ c.getHealth()
				+ "% | Rank: "
				+ c.getLevelName( c.getLevel() )
				+ " "
				+ c.getExperienceToGoInPercentage( c.getExperience(), c
						.getLevel() ) + "% | Shootskill: "
				+ c.getShootExperience() + "% | cash: $" + c.getMoneyCash()
				+ " bank: $" + c.getMoneyBank() + " | ";
	}

	public String getLevelName( int level ) {
		for( Level lvl : Level.values() ) {
			if( lvl.getLevel() == level ) { return lvl.name(); }
		}
		return "ERROR";
	}

	public int getExperienceToGoInPercentage( int xp, int level ) {
		int nextLvl = 1;
		int thisLvl = 0;
		for( Level lvl : Level.values() ) {
			if( lvl.getLevel() == level + 1 ) {
				nextLvl = lvl.getXp();
			}
			if( lvl.getLevel() == level ) {
				thisLvl = lvl.getXp();
			}
		}
		int verschil = nextLvl - thisLvl;
		if( verschil < 1 ) {
			verschil = 1;
		}
		int xpThisLvl = xp - thisLvl;
		return (int) ( ( (float) xpThisLvl / (float) verschil ) * 100.0f );
	}

	public int getBackfire() {
		return backfire;
	}

	public void setBackfire( int backfire ) {
		this.backfire = backfire;
	}
}
